/**
 * 函子：Maybe
 * · 可以过滤空值
 */
class Maybe {
  constructor(value) {
    this.value = value;
  }

  static of(value) {
    return new Maybe(value);
  }

  map(fn) {
    return this.value ? Maybe.of(fn(this.value)) : this;
  }
}

const maybe = Maybe.of(null).map((x) => x.toString());

console.log(maybe);
